<template>
  <div class="vue-table">
    <div class="t-header">
      <span class="no">序号</span>
      <span
        class="t-header-cell"
        v-for="(header, i) in theader"
        :style="{ flex: i == 0 ? 2 : 1 }"
        :key="i"
      >
        {{ header }}
      </span>
    </div>
    <ul class="t-body">
      <div class="move-box">
        <li
          class="t-body-cell"
          v-for="(cell, cellIndex) in data"
          :key="cellIndex"
        >
          <span class="no">{{ cellIndex + 1 }}</span>
          <span
            class="cell-item"
            v-for="(item, idx) in cell"
            :style="{ flex: idx == 'aymc' ? 2 : 1 }"
            :key="idx"
          >
            {{ formatNumber(item) }}
          </span>
        </li>
      </div>
    </ul>
  </div>
</template>

<script setup>
import { ref } from "vue";

defineProps({
  data:{
    type: Array,
    default: () => []
  }
}
)

const theader = ["案由", "收案量", "立案量", "结案量", "存案量", "调撤数"];

const tableData = ref([]);

function formatNumber(num) {
  if (typeof num === "number") {
    return new Intl.NumberFormat().format(num);
  } else {
    return num;
  }
}
</script>

<style lang="scss" scoped>
.vue-table {
  height: 240px;
  overflow: hidden;
  .t-header {
    display: flex;
    height: 40px;
    .no {
      width: 50px;
      text-align: center;
      color: #fff;
    }
    .t-header-cell {
      flex: 1;
      color: #fff;
      text-align: center;
    }
  }
  .t-body {
    overflow: hidden;

    .move-box {
      animation: move 30s linear infinite;
    }

    .t-body-cell {
      display: flex;
      height: 40px;
      &:nth-child(even) {
        background: rgba(#233072, 0.5);
        position: relative;
        &:after {
          content: "";
          position: absolute;
          left: 0;
          bottom: calc(50% - 10px);
          width: 4px;
          height: 20px;
          background: #5572e8;
        }
      }

      span {
        font-size: 14px;
        color: #fff;
        text-align: center;
        line-height: 40px;
      }
      .no {
        width: 50px;
      }
      .cell-item {
      }
    }
  }
}

@keyframes move {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-100%);
  }
}

.vue-table-row {
  position: relative;
  height: 40px;
  width: 100%;
  color: #fff;
  &:not(:first-child):after {
    content: "";
    position: absolute;
    left: 0;
  }
}

.vue-table-row {
  position: relative;
  height: 40px;
  width: 100%;
  color: #fff;
  &:not(:first-child):after {
    content: "";
    position: absolute;
    left: 0;
    bottom: calc(50% - 10px);
    width: 4px;
    height: 20px;
    background: #5572e8;
  }

  /* border-bottom: 1px solid #ccc; */
  &:first-child {
    .vue-table-cell li {
      font-family: MicrosoftYaHei, MicrosoftYaHei;
      font-weight: bold;
      font-size: 14px;
      color: #d0deee;
      line-height: 40px;
      text-align: center;
      font-style: normal;
    }
  }
}

.vue-table-row:nth-child(even) {
  background: rgba(#233072, 0.5);
}

.vue-table-cell {
  display: flex;
  list-style-type: none;
  padding: 0;
  margin: 0;
  height: 40px;
}

.vue-table-cell {
  display: flex;
  list-style-type: none;
  padding: 0;
  margin: 0;
  height: 40px;
  line-height: 40px;
}

.vue-table-cell li {
  text-align: center;
  font-family: MicrosoftYaHei;
  font-size: 14px;
  color: #d0deee;
  text-align: left;
  font-style: normal;
  line-height: 40px;
}
</style>
